{extend name="layout/layout"/}
{block name="content"}
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-header">
                <h4> {$data.title}</h4>
            </div>

            {notempty name="data.tabs"}
            <ul class="nav nav-tabs" style="padding:5px 0 0 10px;">
                {volist name="data.tabs" id="tab"}
                <li class="nav-item">
                    <a class="nav-link {eq name='Request.param.type' value='$tab.type'}active{/eq}" href="{$tab.url}">{$tab.title}</a>
                </li>
                {/volist}

            </ul>
            {/notempty}

            {notempty name="data.info"}
            <p class="mb-0 text-info" style="margin: 5px 10px; padding: 5px; ">{$data.info}</p>
            {/notempty}

            <div class="row">
                <div class="col-xl-12 col-md-12">
                    {notempty name="data.mbuttons"}
                    <div style="display: inline-block; margin: 4px 10px;">

                    {volist name="data.mbuttons" id="mbt"}
                        <a class="btn btn-action {$mbt.class_name??'btn-primary'}" style="margin-bottom: 5px;" href="javascript:;"
                           data-title="{$mbt.title}" data-url="{$mbt.url}" onclick="{$mbt.onclick??'handleClick'}(this, '', '{$mbt.height??''}')"
                        >
                            {if condition="isset($mbt.icon)"}<span class="{$mbt.icon}"></span>{/if}
                            {$mbt.title}

                        </a>
                        {/volist}
                    </div>
                    {/notempty}
                    {notempty name="data.searcher"}
                    <div style="display: inline-block; margin: 4px 10px; margin-left: 0;">
                    <form class="form-inline" action="#" method="get">
                        {volist name="data.searcher" id="sch"}
                        {switch sch.type}
                            {case select }
                            <div class="form-group overflow-hidden">
                                <select class="form-control select2 input-sm" style="margin: 0 5px;">
                                    <option selected="selected">状态</option>
                                    {volist name='sch.option' id='op'}
                                    <option value="{$key}">{$op}</option>
                                    {/volist}
                                </select>
                            </div>
                            {/case}
                            {default /}
                            <div class="form-group" style="margin: 0 5px;">
                                <input class="form-control input-sm" type="text" name="{$sch.name}" placeholder="{$sch.placeholder}"/>
                            </div>
                        {/switch}
                        {/volist}
                            <button type="submit" class="btn btn-sm btn-outline-primary m-b-5 m-t-5">搜索</button>
                        </form>
                    </div>
                    {/notempty}
                </div>
            </div>


            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-striped mb-0 table-hover">
                        <tr>
                            {volist name="data.thead" id="th"}

                            {if condition="is_array($th) && count($th) >= 2"}
                            <th style="{$th[1]}">{$th[0]}</th>
                            {else/}
                            <th>{$th}</th>
                            {/if}

                            {/volist}
                            {notempty name="data.buttons"}<th class="text-right" style='width: {:count($data['buttons']) * 50}px'></th>{/notempty}
                        </tr>
                        {volist name='data.collection' id="row"}
                        <tr id="tr{$row.id}">

                            {volist name="data.fields" id="f"}
                            <td class="">
                                {php}
                                if (is_callable($f)) {
                                echo $f($row);
                                } else {
                                echo $row[$f];
                                }
                                {/php}
                            </td>
                            {/volist}
                            {notempty name="data.buttons"}
                            <td class="text-right row-actions text-nowrap">

                                {volist name="data.buttons" id="bt"}

                                {if condition="isset($bt.type) and $bt.type eq 'link'"}

                                <a class="btn btn-action {$bt.class_name??'btn-primary'}" href="{$bt.url}?id={$row.id}">
                                    {notempty name="bt.icon"}<i class="{$bt.icon}"></i>{/notempty}
                                    {$bt.title}
                                </a>

                                {elseif condition="isset($bt.type) and $bt.type eq 'group'"/}

                                <div class="btn-group">
                                    <a class="btn btn-action btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        操作
                                    </a>
                                    <div class="dropdown-menu">
                                        {volist name="bt.act" id="a"}
                                        <a class="dropdown-item" data-title="{$a.title}" data-url="{$a.url}"
                                           onclick="{$a.onclick??'handleClick'}(this, '{$row.id}')">
                                            {$a.title}
                                        </a>
                                        {/volist}

                                    </div>
                                </div>

                                {else/}

                                <a class=" btn btn-action {$bt.class_name??'btn-primary'}" data-title="{$bt.title}" data-url="{$bt.url}"
                                   onclick="{$bt.onclick??'handleClick'}(this, '{$row.id}', '{$bt.height??''}')">
                                    {notempty name="bt.icon"}<i class="{$bt.icon}"></i>{/notempty}
                                    {$bt.title}
                                </a>

                                {/if}
                                {/volist}




                            </td>
                            {/notempty}
                        </tr>
                        {/volist}

                    </table>

                </div>
                {if condition="method_exists($data.collection, 'total')"}
                <div style="margin: 10px 20px;">
                    合计 {$data.collection->total()}
                    <div style="float:right;" class="page">
                        {$data.collection|raw}
                    </div>
                </div>
                {/if}
            </div>
        </div>
    </div>
</div>
{/block}